# coding:utf-8
import redis

from src import settings


class RedisPool:
    __conn = redis.Redis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB)

    def __init__(self):
        pass

    @classmethod
    def getConn(cls):
        if cls.__conn == None:
            try:
                del cls.__conn
            except:
                pass
            cls.__conn = redis.Redis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB)
        return cls.__conn
